# from devtools import debug
# from pydantic import BaseModel, BaseSettings, Field, ValidationError
# import json
#
# from pydantic.fields import ModelField
# from pydantic.main import ModelMetaclass
#
# from utils.validator_utils.pydantic_validator.parser import parse_model_fields
#
# dic = {
#     "value_error.any_str.min_length": "长度不能少于%(limit_value)d",
#     "value_error.any_str.max_length": "长度不能超过%(limit_value)d"
# }
#
#
# class BaseModelV1(BaseModel):
#     class Config:
#         error_msg_templates = dic
#
#
# class MySettings1(BaseModelV1):
#     name: str = Field(..., title='姓名', min_length=3, max_length=5)
#     age: str = Field(..., title='年龄')
#
#
# class MySettings(BaseModelV1):
#     name: str = Field(..., title='姓名',  min_length=3, max_length=5)
#     data: MySettings1 = Field(..., title='详情')
#
#
# try:
#     settings = MySettings(name="ab1233", data={"name": "1", "age": 2})  # This will raise a validation error
# except ValidationError as e:
#
#     dic = {}
#     parse_model_fields(e.model, dic)
#     debug(dic)
#     debug(e.errors())
#     # debug(e.model)
#     # model_fields: dict[str, ModelField] = e.model.__fields__
#     #
#     # field_dic = {}
#     #
#     # for field_name, field in model_fields.items():
#     #     field_title: str = field.field_info.title or field_name
#     #     debug(field_name, field.field_info.title, field.field_info, field.annotation)
#     #     debug(isinstance(field.annotation, ModelMetaclass))
#     #     debug(issubclass(field.annotation, BaseModel))
#     #
#     #     # if isinstance(field.annotation, ModelMetaclass):
#     #     #     debug(field.annotation.__fields__)
#
#     # # debug(e.model.__dict__)
#     # debug(e.model.__fields__["name"])
#     # debug(e.model.)
#     # name_field = e.model.__fields__["name"]
#     # debug(isinstance(name_field, ModelField))
#     # debug(name_field.field_info.title)
#     # debug(dir(e.model.__fields__["name"]))
#     # # debug(dir(e.model))
#     # # for i in e.errors():
#     # #     msg = i["msg"] % (i["ctx"])
#     # #     debug(msg)
#     # # debug(e.errors())
#     # # print(str(e))
